using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;

namespace Phoenix.Exceptions
{
    [Serializable]
    public class AmbiguousControllerNameException : Exception
    {
        public AmbiguousControllerNameException(string controller, IEnumerable<Type> foundControllers)
            : base(CreateMessage(controller, foundControllers))
        {

        }

#if !WINDOWS_PHONE
        protected AmbiguousControllerNameException(SerializationInfo info, StreamingContext context) : base(info, context)
        {
        }
#endif

        static string CreateMessage(string controller, IEnumerable<Type> foundControllers)
        {
            return string.Format(
                "Controller name '{0}' is ambiguous, {0} exists in {1}",
                controller,
                string.Join(", ", foundControllers.Select(t => t.AssemblyQualifiedName)));
        }
    }
}